package com.example.znyt.utils;

import com.example.znyt.exception.BussinessException;
import com.example.znyt.exception.ErrorCode;

/**
 * @Description 抛出异常断言类
 * @Date 2025/6/11 14:52
 * @Created by 12336
 */

public class ThrowUtils {
    /**
     * 条件成立 也就是condition为true的时候抛出异常
     * @param condition
     * @param runtimeException
     */
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    public  static void throwIf(boolean condition, ErrorCode errorCode) {
        throwIf(condition, new BussinessException(errorCode));
    }

    public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
        throwIf(condition, new BussinessException(errorCode, message));
    }

}
